package com.fsc.mapper;

import com.fsc.entity.domain.ClassInfo;
import com.fsc.entity.domain.StuPartTeach;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 86183
* @description 针对表【stu_part_teach(学生、父母、老师、班级关系表)】的数据库操作Mapper
* @createDate 2024-06-02 13:15:22
* @Entity com.fsc.domain.StuPartTeach
*/
public interface StuPartTeachMapper extends BaseMapper<StuPartTeach> {

	@Select("select class_id from stu_part_teach where student_id = #{studentId}")
	Integer selectByStudentsId(Integer studentId);

	@Select("select student_id from stu_part_teach where teacher_id = #{teacherId};")
	int[] getStuIdsByTeaId(Integer teacherId);

	@Select("select student_id from stu_part_teach where parent_id = #{parentId};")
	int[] getStuIdsByParId(Integer parentId);

	@Select("select class_id from stu_part_teach where student_id = #{id};")
	int getClassIdByStuId(int id);

	@Select("SELECT student_id FROM stu_part_teach WHERE teacher_id = #{teacherId}")
	List<Integer> selectStudentIdsByTeacherId(@Param("teacherId") Integer teacherId);

	@Select("SELECT student_id FROM stu_part_teach WHERE parent_id = #{parentId}")
	List<Integer> selectStudentIdsByParentId(@Param("parentId") Integer parentId);

	@Select("SELECT student_id FROM stu_part_teach WHERE class_id = #{classId}")
	List<Integer> selectStudentIdsByClassId(@Param("classId") Integer classId);


	@Select("SELECT class_id FROM stu_part_teach WHERE teacher_id = #{teacherId} LIMIT 1")
	List<Integer> getClassIdByTeacherId(@Param("teacherId") int teacherId);

	@Select("SELECT class_id FROM stu_part_teach WHERE parent_id = #{parentId} LIMIT 1")
	List<Integer> getClassIdByParentId(@Param("parentId") int parentId);

	@Select("SELECT class_id FROM stu_part_teach WHERE student_id = #{studentId} LIMIT 1")
	List<Integer> getClassIdByStudentId(@Param("studentId") int studentId);

	@Select("SELECT DISTINCT class_id FROM class_info")
	List<Integer> findAllClassIds();
}




